package com.tanhua.server.exeception;

import com.tanhua.model.vo.ErrorResult;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author SunSun
 * @date 2021/10/23
 */
@ControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler
    public ResponseEntity handlerExption(BusinessException be){
        be.printStackTrace();
        ErrorResult errorResult=be.getErrorResult();
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResult);
    }

    @ExceptionHandler
    public ResponseEntity handlerExption1(Exception be){
        be.printStackTrace();
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(ErrorResult.error());
    }
}
